package com.gx.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author: lpj
 * @Date: 2021/7/1 9:45
 * 分页条件
 */
@Data
@ApiModel
public class BaseQueryDto implements Serializable {

    @ApiModelProperty(value = "当前页码")
    private Integer currPage;

    @ApiModelProperty(value = "每页显示条数")
    private Integer pageSize;

    @ApiModelProperty(value = "全部查询")
    private Boolean all;

    //分页参数合理化校验
    public void checkPageParam() {
        if (this.currPage == null || this.currPage <= 0) {
            setCurrPage(1);
        }
        if (this.pageSize == null || this.pageSize <= 0 || this.pageSize > 1000) {
            setPageSize(10);
        }
    }
}
